﻿Chenxin.UI.FundStat = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/FundStat.ashx',
    createSearch: function() {
        return new Chenxin.UI.FundStatSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.GroupReportGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            id: 'search_table',
            renderTo: 'divShowFundList',
            hasCheckBox: false,
            modelId: 'departid',
            autoLoad: false,
            height: 400,
            cellBorder: true,
            hasTotal: true,
            scope: this,
            //			createTitleTool: function() {
            //                return [{
            //                    text: '<span class="simple">导出报表</span>',
            //					scope:this,
            //					title:'导出报表',
            //					handler:function(el){
            //						this.exportData();
            //					}
            //				}];
            //			},
            rowGroupSetting: [
				{ field: 'business', head: '商圈', width: 120, autoCount: true },
				{ field: 'depart', head: '门店', width: 120, autoCount: true }
			],
            columns: {
                /*depart: {
                head: '门店',
                width: 100,
                inTotal: false
                },*/
                oldcommision: {
                    head: '原始应收',
                    width: 120
                },
                curcommision: {
                    head: '当前应收',
                    width: 120
                },
                getcommision: {
                    head: '实收',
                    width: 120
                },
                oldrate: {
                    head: '原始比例',
                    width: 80,
                    hasTotal: false,
                    renderer: function(val, field, row) {
                        return (val * 100).toFixed(2) + '%';
                    }
                },
                currate: {
                    head: '当前比例',
                    width: 80,
                    hasTotal: false,
                    renderer: function(val, field, row) {
                        return (val * 100).toFixed(2) + '%';
                    }
                }
            },
            rowRenderer: function(row, index, dl) {
                if (index == undefined) {
                    if (row.oldcommision == 0)
                        row.oldrate = 0;
                    else
                        row.oldrate = (parseFloat(row.getcommision) / parseFloat(row.oldcommision)).toFixed(4);
                    if (row.curcommision == 0)
                        row.currate = 0;
                    else
                        row.currate = (parseFloat(row.getcommision) / parseFloat(row.curcommision)).toFixed(4);
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;
    },
    initComponent: function() {
        Chenxin.UI.FundStat.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.FundStatSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'search',
    initEvent: function() {
        var _this = this;
        $('#btSearch').click(function() {
            _this.scope.reloadGrid("", 0);
        });
        $("#txtSDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
        $("#txtEDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
        $("#txtSGetDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
        $("#txtEGetDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 100
        });
        var structs = combl.comboList;
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.FundStatSearch.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var FundStat = new Chenxin.UI.FundStat();
});